#include <cstdio>

struct Node
{
    Node *p, *l, *r;
    int size;
    bool revmark;
    short a;
    Node( ) { p = l = r = NULL; size = 1; revmark = 0; }
}*root;

void update( Node *x )
{
    x->size = 1;
    if ( x->l ) x->size += x->l->size;
    if ( x->r ) x->size += x->r->size;
}

void reverse( Node *x )
{
    Node *y = x->l;
    x->l = x->r;
    x->r = y;
    x->revmark ^= 1;
}

void down( Node *x )
{
    if ( x->revmark )
    {
        if ( x->l ) reverse( x->l );
        if ( x->r ) reverse( x->r );
        x->revmark = 0;
    }
}

void zig( Node *x )
{
    Node *y = x->p;
    down( y ); down( x );
    y->l = x->r; if ( x->r ) x->r->p = y;
    x->r = y; x->p = y->p;
    if ( y->p )
        if ( y->p->l == y ) y->p->l = x;
        else y->p->r = x;
    y->p = x;
    if ( y == root ) root = x;
    update( y );
}

void zag( Node *x )
{
    Node *y = x->p;
    down( y ); down( x );
    y->r = x->l; if ( x->l ) x->l->p = y;
    x->l = y; x->p = y->p;
    if ( y->p )
        if ( y->p->l == y ) y->p->l = x;
        else y->p->r = x;
    y->p = x;
    if ( y == root ) root = x;
    update( y );
}

void splay( Node *x, Node *f )
{
    Node *y;
    down( x );
    while ( x->p != f )
    {
        y = x->p;
        if ( y->p == f )
            if ( y->l == x )
                zig( x );
            else
                zag( x );
        else
            if ( y->p->l == y )
                if ( y->l == x )
                    zig( y ), zig( x );
                else
                    zag( x ), zig( x );
            else
                if ( y->r == x )
                    zag( y ), zag( x );
                else
                    zig( x ), zag( x );
    }
    update( x );
}

void select( int k, Node *f )
{
    Node *p = root;
    int s;
    while ( 1 )
    {
        down( p );
        if ( p->l ) s = p->l->size;
        else s = 0;
        if ( k == s + 1 ) break;
        if ( k <= s ) p = p->l;
        else { p = p->r; k -= s + 1; }
    }
    splay( p, f );
}

int n, m;
bool flag;

void print( Node *p )
{
    int i;
    down( p );
    if ( p->l ) print( p->l );
    if ( p->a != 20000 )
    {
        if ( flag ) printf(" ");
        else flag = true;
        printf("%d", p->a);
    }
    if ( p->r ) print( p->r );
    delete( p );
}

int main( )
{
    int i, a, b, c, t, q, l, r, mm;
    Node *p;
    char cmd[ 20 ];
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d", &n);
        root = new Node;
        root->a = 20000;
        for ( i = 1; i <= n; i++ )
        {
            select( i, NULL );
            p = new Node;
            scanf("%d", &q);
            p->a = q;
            root->r = p;
            p->p = root;
            splay( p, NULL );
            select( 1, NULL );
        }
        scanf("%d%d%d", &l, &r, &mm);
        select( i, NULL );
        p = new Node;
        p->a = 20000;
        root->r = p;
        p->p = root;
        splay( p, NULL );
        select( 1, NULL );
        while ( mm-- )
        {
            scanf("%s", cmd);
            if ( cmd[ 0 ] == 'M' && cmd[ 4 ] == 'L' )
            {
                scanf("%s", cmd);
                if ( cmd[ 0 ] == 'L' && l > 1 )
                    l--;
                if ( cmd[ 0 ] == 'R' && r > l + 1 )
                    r--;
            }
            else if ( cmd[ 0 ] == 'M' && cmd[ 4 ] == 'R' )
            {
                scanf("%s", cmd);
                if ( cmd[ 0 ] == 'L' && r > l + 1 )
                    l++;
                if ( cmd[ 0 ] == 'R' && r < n )
                    r++;
            }
            else if ( cmd[ 0 ] == 'D' )
            {
                scanf("%s", cmd);
                if ( cmd[ 0 ] == 'L' )
                {
                    select( l, NULL );
                    select( l + 2, root );
                    p = root->r;
                    delete( p->l );
                    p->l = NULL;
                    p->size--;
                    root->size--;
                    r--;
                    n--;
                    select( 1, NULL );
                }
                if ( cmd[ 0 ] == 'R' )
                {
                    select( r, NULL );
                    select( r + 2, root );
                    p = root->r;
                    delete( p->l );
                    p->l = NULL;
                    p->size--;
                    root->size--;
                    r--;
                    n--;
                    select( 1, NULL );
                }
            }
            else if ( cmd[ 0 ] == 'I' )
            {
                scanf("%s%d", cmd, &q);
                if ( cmd[ 0 ] == 'L' )
                {
                    select( l, NULL );
                    select( l + 1, root );
                    p = root->r;
                    p->l = new Node;
                    p->l->a = q;
                    p->l->p = p;
                    splay( p->l, NULL );
                    select( 1, NULL );
                    r++;
                    n++;
                }
                else
                {
                    select( r + 1, NULL );
                    select( r + 2, root );
                    p = root->r;
                    p->l = new Node;
                    p->l->a = q;
                    p->l->p = p;
                    splay( p->l, NULL );
                    select( 1, NULL );
                    r++;
                    n++;
                }
            }
            else if ( cmd[ 0 ] == 'R' )
            {
                select( l, NULL );
                select( r + 2, root );
                reverse( root->r->l );
            }
            //print( root );puts("");
        }
        flag = false;
        for ( i = 1; i <= n; i++ )
        {
            select( 1, NULL );
            select( 3, root );
            if ( flag ) printf(" ");
            printf("%d", root->r->l->a);
            delete( root->r->l );
            root->r->l = NULL;
            root->size--;
            root->r->size--;
            flag = true;
        }
        printf("\n");
    }
    return 0;
}
